package host.skiree.nettydemo.client.service.impl;

import host.skiree.nettydemo.client.service.MessageClientHandler;
import host.skiree.nettydemo.message.ChatResponseMessage;
import host.skiree.nettydemo.message.Message;
import io.netty.channel.ChannelHandlerContext;

/**
 * @author gcl
 * @date 2022/9/20 9:40
 */
public class Chat implements MessageClientHandler {

    @Override
    public void handleMessage(ChannelHandlerContext ctx, Message message) {
        ChatResponseMessage chatMessage = (ChatResponseMessage) message;
        if (chatMessage.isSuccess()){
            System.out.printf("来自用户 %s 的私聊 : %s\n", chatMessage.getFrom(), chatMessage.getContent());
        }else {
            System.out.printf("私聊失败 : %s\n", chatMessage.getReason());
        }
    }

}
